// 每个实例上面有 __proto__ 指向所属类的原型
// 原型上有 constructor  指向这个类

function Animal(name) {
  this.name = name
}
Animal.prototype.say = function() {
  console.log('说')
}
let p = new Animal('人')

console.log(p.__proto__ === Animal.prototype)  // true
console.log(Animal.prototype.constructor === Animal) // true
console.log(Animal.__proto__ == Function.prototype)
console.log(p.__proto__.__proto__ == Object.prototype)
console.log(Object.prototype.__proto__)  // null


// 类的继承
function Tiger(name) {
  // 继承父类的属性
  Animal.call(this, name)
}

let t1 = new Tiger('老虎')
console.log(t1.name)
// 继承原型上的方法
// 1) Tiger.prototype.__proto__ = Animal.prototype 
Tiger.prototype = Object.create(Animal.prototype, {constructor: Tiger})
function create(prototype) {
  function F() {}
  F.prototype = prototype
  return new F()
}
Tiger.prototype.constructor = Tiger
// 修正 constructor
